import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'package:get/get.dart';
import 'package:wk_robot2/app/widget/CommonWidgets.dart';

import '../../../routes/app_pages.dart';
import '../../../style/app_colors.dart';
import '../controllers/about_account_controller.dart';

class AboutAccountView extends GetView<AboutAccountController> {
  const AboutAccountView({super.key});
  @override
  Widget build(BuildContext context) {
    controller.initData();

    return Scaffold(
      backgroundColor: AppColors.device_page_bg_color,
      appBar: AppBar(
        title: const Text('账号信息'),
        centerTitle: true,
        leading: IconButton(
          icon: Image.asset('assets/images/ic_back2.png',width: 48.w,height: 48.h),
          onPressed: () {
            Get.back();
          },
          tooltip: MaterialLocalizations.of(context).backButtonTooltip, // 可选：设置工具提示
        ),
      ),
      body: Container(
        padding: EdgeInsets.all(40.w),
        child: ListView(
          children: [
            Container(
              margin: EdgeInsets.only(left: 30.w),
              child: Text('个人信息',style: TextStyle(color: AppColors.line_right_character_color,fontSize: 26.sp),),
            ),
            SizedBox(height: 12.h),
            Container(
              decoration: BoxDecoration(
                  borderRadius: BorderRadius.all(Radius.circular(16)),
                  color: Colors.white
              ),
              child: Column(
                children: [
                  GestureDetector(
                    onTap: (){
                      controller.onAvatorClicked();
                    },
                    child: Container(
                      padding: EdgeInsets.only(top: 22.h, bottom: 22.h,left: 30.w,right: 30.w),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Text('头像',style: TextStyle(fontSize: 32.sp),),
                          Image.asset('assets/images/ic_avatar.webp', width: 96.w,height: 96.h,)
                        ],
                      ),
                    ),
                  ),
                  Container(
                    padding: EdgeInsets.only(left: 30.w,right: 30.w),
                    child:  CommonWidgets.getMyDivider(),
                  ),
                  Container(
                    padding: EdgeInsets.only(top: 44.h, bottom: 44.h,left: 30.w,right: 30.w),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text('名称',style: TextStyle(fontSize: 32.sp)),
                        Text('${controller.userName.value}',style: TextStyle(fontSize: 32.sp,color: AppColors.line_right_character_color),)
                      ],
                    ),
                  ),
                ],
              ),
            ),
            SizedBox(height: 38.h),
            Container(
              margin: EdgeInsets.only(left: 30.w),
              child: Text('账户安全',style: TextStyle(color: AppColors.line_right_character_color,fontSize: 26.sp),),
            ),
            SizedBox(height: 12.h),
            Container(
              decoration: BoxDecoration(
                  borderRadius: BorderRadius.all(Radius.circular(16)),
                  color: Colors.white
              ),
              child: Column(
                children: [
                  Container(
                    padding: EdgeInsets.only(top: 44.h, bottom: 44.h,left: 30.w,right: 30.w),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text('绑定手机号',style: TextStyle(fontSize: 32.sp),),
                        Text('${controller.bindPhoneNumber.value}',style: TextStyle(fontSize: 32.sp,color: AppColors.line_right_character_color),)
                      ],
                    ),
                  ),
                  Container(
                    padding: EdgeInsets.only(left: 30.w,right: 30.w),
                    child:  CommonWidgets.getMyDivider(),
                  ),
                  GestureDetector(
                    onTap: () {
                      Get.toNamed(Routes.DISMISS_ACCOUNT);
                    },
                    child: Container(
                      color: Colors.white.withOpacity(0), //仅仅是为了响应点击时间.
                      padding: EdgeInsets.only(top: 44.h, bottom: 44.h,left: 30.w,right: 30.w),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Text('注销账号',style: TextStyle(fontSize: 32.sp)),
                          Image.asset('assets/images/ic_arrow.webp',width: 30.w, height: 30.h)
                        ],
                      ),
                    ),
                  )
                ],
              ),
            ),

            SizedBox(height: 40.h),
            GestureDetector(
              onTap: (){
                showModalBottomSheet(
                  context: context,
                  builder: (BuildContext context) {
                       return Container(
                         decoration: BoxDecoration(
                           borderRadius: BorderRadius.all(Radius.circular(50)),
                           color: AppColors.botom_sheet_bg_color,
                         ),
                         child: Column(
                           mainAxisSize: MainAxisSize.min,
                           children: [
                              Container(
                                padding: EdgeInsets.only(top: 27.h,bottom: 27.h),
                                color: Colors.white,
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.center,
                                  children: [
                                    Text('确定退出登录?',style: TextStyle(color: AppColors.line_right_character_color,fontSize: 26.sp)),
                                  ],
                                ),
                              ),
                              Row(
                                children: [
                                  CommonWidgets.getMyDivider()
                                ],
                              ),
                              GestureDetector(
                                onTap: () {
                                    controller.loginOut();
                                },
                                child: Container(
                                  padding: EdgeInsets.only(top: 27.h,bottom: 27.h),
                                  color: Colors.white,
                                  child: Row(
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: [
                                      Text('退出登录',style: TextStyle(fontSize: 32.sp,color: Colors.red),)
                                    ],
                                  ),
                                ),
                              ),
                              SizedBox(height: 13.h,),
                              GestureDetector(
                                onTap: () {
                                    Get.back();
                                },
                                child: Container(
                                  color: Colors.white,
                                  padding: EdgeInsets.only(top: 27.h,bottom: 27.h),
                                  child: Row(
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: [
                                      Text('取消',style: TextStyle(fontSize: 32.sp),)
                                    ],
                                  ),
                                ),
                              )
                              ,

                           ],
                         ),
                       );
                  }

                );
              },
              child: Container(
                padding: EdgeInsets.only(top:30.h,bottom: 30.h),
                decoration: BoxDecoration(
                    borderRadius: BorderRadius.all(Radius.circular(16)),
                    color: Colors.white
                ),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Text('退出登录',style: TextStyle(fontSize: 32.sp))
                  ],
                ),
              ),
            )


          ],
        ),
      ),
    );
  }
}
